package com.app.megaprosoft.modyimcarcare;





import com.megaprosoft.modyimcarcare.R;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {


	String NameInput,company; 
	
	public static final String PREFS_NAME = "LoginPrefs";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		setContentView(R.layout.a_carcare_activity_main);
		
		
		final Button btn1 = (Button) findViewById(R.id.button1);
		final Button btn2 = (Button) findViewById(R.id.button2);
//		final Button btn3 = (Button) findViewById(R.id.a_carcare_password);
//		final Button bte = (Button) findViewById(R.id.a_carcare_password);
		
		
		NameInput = getIntent().getExtras().getString("name");
		company = getIntent().getExtras().getString("CompanyS");
		
		
	//	Toast.makeText(MainActivity.this, "Inserted data successfully"+NameInput+company, Toast.LENGTH_SHORT).show();
		
		
		
		
		///////////////////////////////// �Ѻ��ԡ��
		btn1.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				btn1.setBackgroundColor(Color.GREEN);
				//Open Form newActivityActritis
				Intent newActivityActritis = new Intent(MainActivity.this,InitialServices.class);
				//newActivityActritis.putExtras(newActivityActritis);
				newActivityActritis.putExtra("name", NameInput);
				newActivityActritis.putExtra("CompanyS", company);
				startActivity(newActivityActritis);
				
				

			}



			});
		
		btn2.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				if(isConnectInternet()){
					btn2.setBackgroundColor(Color.GREEN);
				//Open Form newActivityActritis
				Intent newActivityActritis = new Intent(MainActivity.this,Search.class);
				newActivityActritis.putExtra("name", NameInput);
				newActivityActritis.putExtra("CompanyS", company);
				startActivity(newActivityActritis);
				
				}else{
					Toast.makeText(MainActivity.this, "������������� Internet", Toast.LENGTH_SHORT).show();
				}

			}



			});
		
		
//		btn3.setOnClickListener(new View.OnClickListener() {
//			public void onClick(View v) {
//				if(isConnectInternet()){
//					btn3.setBackgroundColor(Color.GREEN);
//				//Open Form newActivityActritis
//				Intent newActivityActritis = new Intent(MainActivity.this,Detail.class);
//				newActivityActritis.putExtra("name", NameInput);
//				newActivityActritis.putExtra("CompanyS", company);
//				startActivity(newActivityActritis);
//				
//			}else{
//				Toast.makeText(MainActivity.this, "������������� Internet", Toast.LENGTH_SHORT).show();
//			}
//
//			}

//
//
//			});
//		
//		bte.setOnClickListener(new View.OnClickListener() {
//			
//			
//			public void onClick(View v) {
//			 
//				bte.setBackgroundColor(Color.GREEN);
//					// �͡�����
//					Intent intent = new Intent(Intent.ACTION_MAIN);
//					intent.addCategory(Intent.CATEGORY_HOME);
//					intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//					startActivity(intent);
//				}      	
//
//			});
//		
//		
//		btn3.setOnClickListener(new View.OnClickListener() {
//			
//			
//			public void onClick(View v) {
//			 
//				btn3.setBackgroundColor(Color.GREEN);
//				////// logout
//					Intent newActivityActritis = new Intent(MainActivity.this,Carcare_Main.class);
//					startActivity(newActivityActritis);
//					
//					
//
//				}      	
//
//			});
		
		}
	
	
	public boolean isConnectInternet(){
		ConnectivityManager connect = (ConnectivityManager) 
				getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
		if (connect != null){
			NetworkInfo[] info = connect.getAllNetworkInfo();
			if (info != null) 
				for (int i = 0; i < info.length; i++) 
					if(info[i].getState() == NetworkInfo.State.CONNECTED){
						return true;
					}
			}
		  return false;
	}



@Override
public void onBackPressed() {
  
        

}

}
